﻿<%@ Page Language="C#" AutoEventWireup="true" Codebehind="RoleList.aspx.cs" Inherits="LabMS.Web.Role.RoleList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>角色列表</title>
    <link type="text/css" rel="stylesheet" href="../style/screen.css" />
    <!--[if lte IE 6]>
    <link type="text/css" rel="stylesheet" href="../style/ie6.css" />
    <![endif]-->
    <!--[if lte IE 7]>
    <link type="text/css" rel="stylesheet" href="../style/ie7.css" />
    <![endif]-->
</head>
<body class="mainBody">
    <form id="form1" runat="server">
        <div class="main">
            <div id="pageInfo" class="clearfix">
                <div class="title">
                    <label>
                        角色管理</label>
                </div>
            </div>
        </div>
        <div class="main">
            <p>
                <input type="button" class="button" value="新增" onclick="javascript:window.location.href='Add.aspx'" />
                <%--<asp:Button ID="btnAddRole" runat="server" Text="增加" OnClick="btnAddRole_Click" CssClass="button" />--%>
                <asp:Button ID="btnCancle" runat="server" Text="删除" OnClick="btnCancle_Click" CssClass="button" />
            </p>
            <p>
                <span>角色名：</span><asp:TextBox ID="tbRoleNameSerach" runat="server"></asp:TextBox>
                <asp:Button ID="search" runat="server" Text="搜索" CssClass="button" OnClick="search_Click" />
            </p>
        </div>
        <div class="main">
            <asp:GridView ID="gvRole" runat="server" AutoGenerateColumns="false" DataKeyNames="RoleId"
                CssClass="infoTable" Width="98%" OnRowDataBound="gvRole_RowDataBound" OnRowCommand="gvRole_RowCommand"
                AllowPaging="true" OnPageIndexChanging="gvRole_PageIndexChanging" PageSize="15" OnRowCreated="gvRole_RowCreated">
                <Columns>
                    <asp:TemplateField ItemStyle-CssClass="checkBox">
                        <HeaderTemplate>
                            <asp:CheckBox ID="CBAll" runat="server" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="Chk" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="RoleId" Visible="false" />
                    <%--<asp:HyperLinkField DataTextField="RoleName" HeaderText="角色名" ItemStyle-Width="35%"
                        DataNavigateUrlFormatString="Edit.aspx?RoleName={0}" DataNavigateUrlFields="RoleName" />--%>
                    <asp:BoundField DataField="RoleName" HeaderText="角色名" />
                    <asp:BoundField DataField="RoleDetails" HeaderText="角色描述" ItemStyle-Width="50%" />
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:LinkButton ID="LBshowuser" runat="server" Text="查看用户" CommandName="ShowUser"></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EmptyDataTemplate>
                    无角色内容
                </EmptyDataTemplate>
                <HeaderStyle CssClass="header" />
                <PagerSettings FirstPageText="首页" LastPageText="最后页" NextPageText="后一页" PreviousPageText="前一页"
                    Mode="NextPreviousFirstLast" />
            </asp:GridView>
        </div>
    </form>
</body>
</html>

<script type="text/javascript" src="../js/jQuery/jquery-1.3.1.js"></script>

<script type="text/javascript">
        $(function(){
            /* 修改样式 */
            $("#gvRole > tbody > tr:even").not(":first").addClass("even");
            $("#gvRole > tbody > tr").not(":first")
                .hover(
                    function(){
                        $(this).addClass("hover");
                    },
                    function(){
                        $(this).removeClass("hover");
                });

            /* 全选 */
            $("#gvRole > tbody > tr:first :checkbox").click(function(){
                if ($(this).attr("checked")){
                    $("#gvRole :checkbox").attr("checked", "checked");
                    cbChanged();
                } else{
                    $("#gvRole :checkbox").attr("checked", "");
                    cbChanged();
                }
            });

            /* Checkbox事件 */
            $("#gvRole :checkbox").not(":first").click(cbChanged);

            cbChanged();
        });

        /* 检测Checkbox的选择状态，更改button的disabled属性 */
        function cbChanged(){
            var hasChecked = false;
            var allChecked = true;
            $("#gvRole :checkbox").not(":first").each(function(index, domEle){
                var curChecked = $(domEle).attr("checked");
                if (!hasChecked && curChecked){
                    hasChecked = true;
                }

                allChecked &= curChecked;
            });

            if (hasChecked){
                $("#btnCancle").attr("disabled", "");
            } else {
                $("#btnCancle").attr("disabled", "disabled");
            }

            if (allChecked){
                $("#gvRole :checkbox").filter(":first").attr("checked", "checked");
            } else {
                $("#gvRole :checkbox").filter(":first").attr("checked", "");
            }
        }
</script>

